// token相关
const jwt = require('jsonwebtoken');
let { salt, expiresIn } = require('../config');

// 生成token
let createToken = (data) => {
  return jwt.sign(data, salt, { expiresIn })
}
// 校验token
let veifyToken = (token) => {
  return new Promise(resolve => {
    jwt.verify(token, salt, (err, info) => {
      if (err) return resolve({ status: 0, message: err.message })
      resolve({ status: 1, info })
    })
  })
}



module.exports = {
  createToken, veifyToken
}
